<style type="text/css">
.layui-form-item{margin-bottom:12px;}
.layui-form-label{width:100px;}
</style>
<form class="layui-form layui-form-item" lay-filter="add-form" action="{:url('')}" method="post" id="editForm" style="margin-top:8px;">
    {:FormExt::setInline()}
    {:FormExt::input('物料SKU', 'material_sku', $info['material_sku'], '请输入物料SKU', '', 'readonly')}
    {:FormExt::input('订单号/采购批号', 'res_id', $info['res_id'], '请输入订单号', '', 'readonly')}
    {:FormExt::select('工厂', 'factory_id', $info['factory_id'], $factoryKV, '', '')}
<!--    {:FormExt::select('单位', 'unit', $info['unit'], $unitKV, '', '')}-->
	{:FormExt::select('物料属性', 'stock_m_type',$info['stock_m_type'], ['0' => '常规料', '1' => '备料', '2' => '余料'], '', '')}
    {:FormExt::input('数量', 'use_num', '', '请输入数量', 'required', 'lay-verify="number"')}
    {:FormExt::input('布号/物料id', 'cloth_num', '', '请输入物料id', 'required', 'lay-verify=""')}
    {:FormExt::select('* 货仓', 'storehouse_id', '', $storehouseKV, '', 'required', 'lay-filter="storehouse-id"')}
    {:FormExt::select('货架', 'storeshelf_id', '', [], '', 'required')}
    {:FormExt::input('备注', 'remark', '', '请输入备注', '', 'lay-verify=""')}
    <div class="pop-bottom-bar">
        <input type="hidden"  name="mid" value="{$info['mid']}">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: false, callback: callbackUpdateStock}">提交并入库</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

{include file="system@block/layui" /}
    
<script type="text/javascript">
    var storeshelfMap = {:json_encode($storeshelfMap)};
    layui.use(['tool', 'form'], function() {
    	var $ = layui.jquery;
    	var form = layui.form;
    	
    	

    	// 表单提交回调
    	window.callbackUpdateStock = function(obj, res) {
			setTimeout(function(){
				parent.layer.closeAll();
			},3000);
    	}
        // 货仓下拉切换
        form.on('select(storehouse-id)', function(data){
            var optionArr = storeshelfMap[data.value];
            var option = '';
            for(var i in optionArr) {
                option += '<option value="'+i+'">'+optionArr[i]+'</option>';
            }
            $("select[name=storeshelf_id] option").remove();
            $('select[name=storeshelf_id]').append(option);
            form.render();
        });
		$('input[name=use_num]').focus();
    });
</script>